#include <stdio.h>
#include <stdlib.h>
#include <time.h>

 struct domino{
int v1;
int v2;
};
typedef struct domino dom;
dom td[28];
dom dj1[21];
dom dj2[21];

void choix_ntd(int * ntd)
{int i,j;
int ndj1[28];
int x;
printf("les 7 dominos du joueur 1 sont :\n");
		for(i=0 ; i<1 ; i++)
			{
            scanf("%d",&x);
			    printf("\n");
			    if(x==1){
				dj1[i].v1 = ntd[i]/10;

				dj1[i].v2 = ntd[i]-dj1[i].v1*10;


				//dj1[i]=td[i].v1;
				//dj1[i]=td[i].v1;
printf(" [%d|%d]",dj1[0].v1,dj1[0].v2);
printf("\n");}}
		for(i=1 ; i<2 ; i++)
			{printf("\n");
			    scanf("%d",&x);
			    if(x==1){
				dj1[i].v1 = ntd[i]/10;
				dj1[i].v2 = ntd[i]-dj1[i].v1*10;


printf(" [%d|%d]",dj1[1].v1,dj1[1].v2);

}}
for(i=2 ; i<3; i++)
			{printf("\n");
			    scanf("%d",&x);

			    if(x==1){
				dj1[i].v1 = ntd[i]/10;
				dj1[i].v2 = ntd[i]-dj1[i].v1*10;


printf(" [%d|%d]",dj1[2].v1,dj1[2].v2);

}}
for(i=3 ; i<4 ; i++)
			{printf("\n");
			    scanf("%d",&x);

			    if(x==1){
				dj1[i].v1 = ntd[i]/10;
				dj1[i].v2 = ntd[i]-dj1[i].v1*10;


printf(" [%d|%d]",dj1[3].v1,dj1[3].v2);

}}
for(i=4 ; i<5 ; i++)
			{
			    printf("\n");
			    scanf("%d",&x);

			    if(x==1){
				dj1[i].v1 = ntd[i]/10;
				dj1[i].v2 = ntd[i]-dj1[i].v1*10;


printf(" [%d|%d]",dj1[4].v1,dj1[4].v2);

}}
for(i=5 ; i<6 ; i++)
			{printf("\n");
			    scanf("%d",&x);

			    if(x==1){
				dj1[i].v1 = ntd[i]/10;
				dj1[i].v2 = ntd[i]-dj1[i].v1*10;


printf(" [%d|%d]",dj1[5].v1,dj1[5].v2);

}}
for(i=6 ; i<7 ; i++)
			{printf("\n");
			    scanf("%d",&x);
			    if(x==1){
				dj1[i].v1 = ntd[i]/10;
				dj1[i].v2 = ntd[i]-dj1[i].v1*10;


printf(" [%d|%d]",dj1[6].v1,dj1[6].v2);

}}}
void choix_ntd2(int * ntd)   {
    int i,j;
int ndj2[28];
int x;
printf("\n");
printf("les 7 dominos du joueur 2 sont :\n");
		for(i=7 ; i<8 ; i++)
			{
            scanf("%d",&x);
			    printf("\n");
			    if(x==1){
				dj2[i].v1 = ntd[i]/10;

				dj2[i].v2 = ntd[i]-dj2[i].v1*10;

				//dj1[i]=td[i].v1;
				//dj1[i]=td[i].v1;
printf(" [%d|%d]",dj2[7].v1,dj2[7].v2);
printf("\n");}}
		for(i=1 ; i<2 ; i++)
			{printf("\n");
			    scanf("%d",&x);
			    if(x==1){
				dj2[i].v1 = ntd[i]/10;
				dj2[i].v2 = ntd[i]-dj2[i].v1*10;


printf(" [%d|%d]",dj2[8].v1,dj2[8].v2);

}}
for(i=9; i<10; i++)
			{printf("\n");
			    scanf("%d",&x);

			    if(x==1){
				dj2[i].v1 = ntd[i]/10;
				dj2[i].v2 = ntd[i]-dj2[i].v1*10;


printf(" [%d|%d]",dj2[9].v1,dj2[9].v2);

}}
for(i=10 ; i<11 ; i++)
			{printf("\n");
			    scanf("%d",&x);

			    if(x==1){
				dj2[i].v1 = ntd[i]/10;
				dj2[i].v2 = ntd[i]-dj2[i].v1*10;


printf(" [%d|%d]",dj2[10].v1,dj2[10].v2);

}}
for(i=11; i<12 ; i++)
			{
			    printf("\n");
			    scanf("%d",&x);

			    if(x==1){
				dj2[i].v1 = ntd[i]/10;
				dj2[i].v2 = ntd[i]-dj2[i].v1*10;


printf(" [%d|%d]",dj2[11].v1,dj2[11].v2);

}}
for(i=12; i<13 ; i++)
			{printf("\n");
			    scanf("%d",&x);

			    if(x==1){
				dj2[i].v1 = ntd[i]/10;
				dj2[i].v2 = ntd[i]-dj2[i].v1*10;


printf(" [%d|%d]",dj2[12].v1,dj2[12].v2);

}}
for(i=13 ; i<14 ; i++)
			{printf("\n");
			    scanf("%d",&x);
			    if(x==1){
				dj2[i].v1 = ntd[i]/10;
				dj2[i].v2 = ntd[i]-dj2[i].v1*10;


printf(" [%d|%d]",dj2[13].v1,dj2[13].v2);

}}/*
for(i=0;i<28;i++){
if ((dj1[0].v1==td[i].v1 && dj1[0].v2==td[i].v2)||(dj1[1].v1==td[i].v1 && dj1[1].v2==td[i].v2)||(dj1[2].v1==td[i].v1 && dj1[2].v2==td[i].v2)||(dj1[3].v1==td[i].v1 && dj1[3].v2==td[i].v2)||(dj1[4].v1==td[i].v1 && dj1[4].v2==td[i].v2)||(dj1[5].v1==td[i].v1 && dj1[5].v2==td[i].v2)||(dj1[6].v1==td[i].v1 && dj1[6].v2==td[i].v2)){

    {
        for(j=i;j<28;j++){
        td[j].v1=td[j+1].v1;
         td[j].v2=td[j+1].v2;}
         i--;}}
         else {
            td[i]=td[i+1];
         }


printf("%d %d", td[i].v1, td[i].v2);}*/


 return 0; }
				//printf(" [%d|%d]\n ",ipos[td[i].v1][td[i].v2]);}


			/*
for (i=0;i<28;i++){


    if (ntd[i]==ipos[i]){
            for (j=i;j<28;j++){
   ntd[j]=ntd[j+1];}

i--;
            }}
            for(j=0;j<28; j++)

   printf("%d|",ntd[j]);
				printf("\n");
/*

*/
int main(){

int player[2][14],randomino;
int i,j,k=0;
int h=0;
int ntd[28];

printf("les 28 dominos sont \n");
for (i=0;i<7;i++){//0-->6=7:00,01,02,03,04,05,06
    td[i].v1=0;
   td[i].v2=i;
   ntd[i]=i;
}
printf("\n");
for (i=7;i<13;i++){//0-->5=6 11,12,13,14,15,16
    td[i].v1=1;
   td[i].v2=i-6;
   ntd[i]=i;
}
for (i=13;i<18;i++){//0-->4=5:22,23,24,25,26
    td[i].v1=2;
   td[i].v2=i-11;
   ntd[i]=i;
}
for (i=18;i<22;i++){//0-->3=4:33,34,35,36
    td[i].v1=3;
   td[i].v2=i-15;
   ntd[i,i]=i;
}
for (i=22;i<25;i++){//0-->2=3:44,45,46
    td[i].v1=4;
   td[i].v2=i-18;
   ntd[i]=i;
}
for (i=25;i<27;i++){//0--1=2:55,56
    td[i].v1=5;
   td[i].v2=i-20;
   ntd[i]=i;
}
for (i=27;i<28;i++){//1:66
    td[i].v1=6;
   td[i].v2=i-21;
   ntd[i]=i;
}
printf("\n");
for (i=0;i<28;i++){
    printf("%7d==> [%d|%d]\n",ntd[i],td[i].v1,td[i].v2);

    printf("\n");

}

printf("\n");

		srand((int) time(NULL));
		for(i = 0 ; i <7 ; i++)
			for(j = i ; j <7; j ++)
				{
                ntd[k++] = i*10 + j ;


				}
for(i=0 ; i<7 ; i++)
			{
    for(j=0 ; j<2 ; j++)
					{
do
{
randomino = (double) rand()/(RAND_MAX + 1) *28;

 player[j][i] = ntd[randomino] ;

} while(ntd[randomino] == 0) ;


    ntd[randomino] = 0 ;
					}
			}
		choix_ntd(player[1]) ;

		choix_ntd2(player[2]) ;



		return 0;

}
/*
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

 struct domino{
int v1;
int v2;
};
typedef struct domino dom;
dom td[28];

void choix_ntd(int * ntd)
{int i;
		for(i=0 ; i<7 ; i++)
			{
				td[i].v1 = ntd[i]/10;

				td[i].v2 = ntd[i]-td[i].v1*10;
//if( td[i].v2>0&&td[i].v2<7 )
				printf(" [%d|%d] ",td[i].v1,td[i].v2);

			}
			printf("\n");

		return ;}
int main(){
int ntd[28];
int player[2][7],randomino;
int i,j,k=0;
printf("les 28 dominos sont \n");
for (i=0;i<7;i++){//0-->6=7:00,01,02,03,04,05,06
    td[i].v1=0;
   td[i].v2=i;
   ntd[i]=i;
}
printf("\n");
for (i=7;i<13;i++){//0-->5=6 11,12,13,14,15,16
    td[i].v1=1;
   td[i].v2=i-6;
   ntd[i]=i;
}
for (i=13;i<18;i++){//0-->4=5:22,23,24,25,26
    td[i].v1=2;
   td[i].v2=i-11;
   ntd[i]=i;
}
for (i=18;i<22;i++){//0-->3=4:33,34,35,36
    td[i].v1=3;
   td[i].v2=i-15;
   ntd[i]=i;
}
for (i=22;i<25;i++){//0-->2=3:44,45,46
    td[i].v1=4;
   td[i].v2=i-18;
   ntd[i]=i;
}
for (i=25;i<27;i++){//0--1=2:55,56
    td[i].v1=5;
   td[i].v2=i-20;
   ntd[i]=i;
}
for (i=27;i<28;i++){//1:66
    td[i].v1=6;
   td[i].v2=i-21;
   ntd[i]=i;
}
printf("\n");
for (i=0;i<28;i++){
    printf("%7d==> [%d|%d]\n",ntd[i],td[i].v1,td[i].v2);
}
printf("\n");
printf("les 7 dominos du joueur 1 sont :\n");
		srand((int) time(NULL));
		for(i = 0 ; i < 7 ; i++)
			for(j = i ; j < 7 ; j ++)
				{
                ntd[k++] = i*10 + j ;

				}
for(i=0 ; i<7 ; i++)
			{
    for(j=0 ; j<2 ; j++)
					{
do
{
randomino = (double) rand()/(RAND_MAX + 1) *28;

 player[j][i] = ntd[randomino] ;

} while(ntd[randomino] == 0) ;


    ntd[randomino] = 0 ;
					}
			}
		choix_ntd(player[1]) ;

		return 0;
}

	*/
